package com.zp.security.oauth2.customized;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * 自定义电子邮件认证令牌，类似于UsernamePasswordAuthenticationToken
 *
 * @author zp
 */
public class EmailAuthenticationToken extends AbstractAuthenticationToken {
    private final Object principal;
    private Object credentials;

    public EmailAuthenticationToken(String email,String password ) {
        super(null);
        this.principal=email;
        this.credentials=password;
        setAuthenticated(false);
    }
    public EmailAuthenticationToken(String email, String password, Collection<? extends GrantedAuthority> authorities ) {
        super(authorities);
        this.principal=email;
        this.credentials=password;
        setAuthenticated(false);
    }

    @Override
    public Object getCredentials() {
        return this.credentials;
    }

    @Override
    public Object getPrincipal() {
        return this.principal;
    }
    @Override
    public void setAuthenticated(boolean authenticated){
        super.setAuthenticated(authenticated);
    }
    @Override
    public void eraseCredentials(){
        super.eraseCredentials();
    }
}
